import React from "react";
import Field from './Field';
export default class App extends React.Component{
    state={
        username:localStorage.getItem("username")?localStorage.getItem("username"):'',
        password:''
    }
    render(){
        return(
            <div>
                <h2>用户登录</h2>
                <Field label="用户名" type="text" changeEvent={(v)=>{
                    this.setState({username:v})
                }} value={this.state.username}/>
                <Field label="密码" type="password" changeEvent={(v)=>{
                    this.setState({password:v})
                }} value={this.state.password}/>
                <button onClick={()=>{console.log('登陆成功')}}>登陆</button>
                <button onClick={()=>{
                    this.setState({
                        username:'',
                        password:''
                    })
                }}>清空</button>
            </div>
        )
    }
}